﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Xml;
using System.Xml.XPath;
using System.Windows.Forms;
using BierdopjeTV.API;

namespace BierdopjeTV.Helpers
{
    static class XMLHelper
    {
        public static XmlDocument getXML(string url)
        {
            
            string xmlResponse = HTTPHelper.GetHTTPResponse(url);

            XmlDocument xmlDOC = new XmlDocument();
            //Response kan null zijn / empty/geen r00t element
            try
            {

                xmlDOC.LoadXml(xmlResponse);
            }
            catch (Exception ex)
            {
                Helpers.Logger.Write(ex.Message, "getXML()");
            }

            return xmlDOC;
        }

        public static int getNodeCount(XmlDocument xmlDoc, string XPathQuery)
        {
            return xmlDoc.SelectNodes(XPathQuery).Count;
        }



    }










}
